package com.yjq.programmer.controller.admin;

import com.yjq.programmer.dto.MusicDTO;
import com.yjq.programmer.dto.MusicMenuDTO;
import com.yjq.programmer.dto.PageDTO;
import com.yjq.programmer.dto.ResponseDTO;
import com.yjq.programmer.service.IMusicService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 杨杨吖
 * @QQ 823208782
 * @WX yjqi12345678
 * @create 2022-11-12 15:41
 */
@RestController("AdminMusicController")
@RequestMapping("/admin/music")
public class MusicController {

    @Resource
    private IMusicService musicService;

    /**
     * 分页获取音乐数据
     * @param pageDTO
     * @return
     */
    @PostMapping("/list")
    public ResponseDTO<PageDTO<MusicDTO>> getMusicListByPage(@RequestBody PageDTO<MusicDTO> pageDTO){
        return musicService.getMusicListByPage(pageDTO);
    }

    /**
     * 保存音乐数据(添加、修改)
     * @param musicDTO
     * @return
     */
    @PostMapping("/save")
    public ResponseDTO<Boolean> saveMusic(@RequestBody MusicDTO musicDTO){
        return musicService.saveMusic(musicDTO);
    }

    /**
     * 删除音乐数据
     * @param musicDTO
     * @return
     */
    @PostMapping("/remove")
    public ResponseDTO<Boolean> removeMusic(@RequestBody MusicDTO musicDTO){
        return musicService.removeMusic(musicDTO);
    }

    /**
     * 获取音乐总数
     * @return
     */
    @PostMapping("/total")
    public ResponseDTO<Integer> getMusicTotal(){
        return musicService.getMusicTotal();
    }

    /**
     * 根据歌单id获取音乐数据
     * @param musicMenuDTO
     * @return
     */
    @PostMapping("/getByMusicMenuId")
    public ResponseDTO<List<MusicDTO>> appGetMusicListByMusicMenuId(@RequestBody MusicMenuDTO musicMenuDTO) {
        return musicService.getMusicListByMusicMenuId(musicMenuDTO);
    }

    /**
     * 获取全部音乐数据
     * @return
     */
    @PostMapping("/all")
    public ResponseDTO<List<MusicDTO>> getAllMusicList() {
        return musicService.getAllMusicList();
    }
}
